package com.tyk.bookstore.front.order.util;


import com.tyk.bookstore.front.cart.model.dto.Cart4OrderDto;
import com.tyk.bookstore.front.member.model.dto.Address4OrderDto;
import com.tyk.bookstore.front.order.dto.Order4StockDto;
import com.tyk.bookstore.front.order.dto.OrderDetail4StockDto;
import com.tyk.bookstore.front.order.model.dto.OrderDetailDto;
import com.tyk.bookstore.front.order.model.dto.OrderExplicitDto;
import com.tyk.bookstore.front.order.model.dto.OrderSubmitDto;
import com.tyk.bookstore.front.order.model.entity.OrderDetailDo;
import com.tyk.bookstore.front.order.model.entity.OrderDo;
import com.tyk.bookstore.front.order.model.entity.OrderExtraDo;
import com.tyk.bookstore.front.order.model.query.OrderAddressUpdateQuery;
import com.tyk.bookstore.front.order.model.vo.*;
import com.tyk.bookstore.front.order.strategy.split.model.SplitDto;
import com.tyk.bookstore.front.order.strategy.split.model.SplitStock;
import com.tyk.bookstore.front.order.vo.OrderAddressVo;
import com.tyk.bookstore.front.order.vo.OrderSplitSubDto;
import com.tyk.bookstore.front.order.vo.OrderSplitVo;
import com.tyk.bookstore.front.product.model.dto.Book4OrderCommentSuggestionDto;
import com.tyk.bookstore.front.product.model.dto.Book4OrderDto;
import com.tyk.bookstore.front.product.model.query.Book4OrderPriceCheckQuery;
import com.tyk.bookstore.front.storage.model.query.Stock4OrderDeductQuery;
import com.tyk.bookstore.front.storage.model.query.Stock4OrderRollBackQuery;
import com.tyk.bookstore.front.storage.model.query.Stock4OrderStockMeetQuery;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

@Mapper(componentModel = "spring")
public interface MapStructOrder {

    List<OrderVo.OrderDetailVo> toOrderVo$OrderDetailVo(List<OrderDetailDo> orderDetailList);

    OrderCreateVo.OrderDetailVo toOrderSubmitVo$OrderDetailVo(Cart4OrderDto cart, Book4OrderDto boo);

    List<Book4OrderPriceCheckQuery> toBook4OrderPriceCheckQuery(List<OrderCreateVo.OrderDetailVo> detailList);

    List<SplitStock> toSplitParamList(List<OrderCreateVo.OrderDetailVo> detailList);

    OrderDo toOrderDo(OrderDo order);

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "orderId", ignore = true),
            @Mapping(target = "memberId", ignore = true),
            @Mapping(target = "commentId", ignore = true)}
    )
    OrderDetailDo toOrderDetailDo(OrderCreateVo.OrderDetailVo detailVo);

    List<OrderDetailDo> toOrderDetailDoList(List<OrderCreateVo.OrderDetailVo> detailList);


    List<OrderPageVo.OrderDetail> toOrderPageVo$OrderDetailList(List<OrderDetailDto> orderDetailDtoList);

    @Mappings({@Mapping(target = "orderId", source = "id"), @Mapping(target = "deadline", source = "createTime")})
    OrderSubmitVo toOrderSubmitVo(OrderSubmitDto submitDto);

    List<Stock4OrderRollBackQuery.Stock> toStock4OrderRollBackQuery$StockRollBack(List<OrderDetail4StockDto> orderDetail4StockDtoList);

    List<Stock4OrderRollBackQuery.Stock> toStock4OrderRollBackQuery$StockRollBackList(List<Order4StockDto> order4StockDtoList);

    List<Stock4OrderDeductQuery> toStock4OrderDeductQueryList(List<SplitDto> splitList);

    List<Stock4OrderStockMeetQuery> toStock4OrderStockMeetQueryList(List<SplitStock> splitStockList);


    List<OrderSplitVo.Order> toOrderSplitVo$OrderList(List<OrderSplitSubDto> dtoList);


    @Mappings({
            @Mapping(target = "cneeName", source = "consignee"),
            @Mapping(target = "cneePhone", source = "phone"),
            @Mapping(target = "cneeAreaCode", source = "areaCode"),
            @Mapping(target = "cneeAddress", source = "address"),
    })
    OrderExtraDo toOrderExtraDo(Address4OrderDto address);

    OrderVo toOrderVo(OrderDo order, OrderExtraDo orderExtra);

    OrderSplitVo toOrderSplitVo(OrderDo order, OrderExtraDo orderExtra);

    @Mappings({
            @Mapping(target = "id", source = "oc.id"),
            @Mapping(target = "orderNo", source = "oc.orderNo"),
            @Mapping(target = "amount", source = "oc.amount"),
            @Mapping(target = "state", source = "oc.state"),
            @Mapping(target = "createTime", source = "oc.createTime"),
            @Mapping(target = "cneeName", source = "oe.cneeName"),
            @Mapping(target = "paymentWay", source = "oe.paymentWay"),
    })
    OrderPageVo.Order toOrderPageVo$Order(OrderExplicitDto oc, OrderExplicitDto oe);

    OrderAddressVo toOrderAddressVo(OrderExtraDo order);

    OrderExtraDo toOrderExtraDo(OrderAddressUpdateQuery query);

    List<WaitCommentVo> toWaitCommentVoList(List<Book4OrderCommentSuggestionDto> bookList);

    @Mappings({
            @Mapping(target = "bookId", source = "id"),
            @Mapping(target = "bookName", source = "name")
    })
    WaitCommentVo toWaitCommentVoList(Book4OrderCommentSuggestionDto book);

}
